using System.BusinessObjects.Transactions;
using NHibernate;
using NHibernate.Criterion;
using Blazing.BusinessObjects.Assets;

namespace Blazing.BusinessObjects.Queries
{
    public class QrySearchAssets
    {
        public static ICriteria Query()
        {
            ICriteria qry = UnitOfWork.CurrentSession.CreateCriteria(typeof(Asset));
            qry.AddOrder(Order.Asc("Name"));
            return qry;
        }

        public static ICriteria Query(int taxonomyTagId)
        {
            ICriteria qry = UnitOfWork.CurrentSession.CreateCriteria(typeof(Asset));
            qry.Add(Expression.Eq("TaxonomyTag.ID", taxonomyTagId));
            qry.AddOrder(Order.Asc("Name"));

            return qry;
        }

        public static ICriteria Query(string path)
        {
            ICriteria qry = UnitOfWork.CurrentSession.CreateCriteria(typeof(Asset));
            qry.Add(Expression.Eq("FilePath", path));
            qry.AddOrder(Order.Asc("Name"));

            return qry;
        }
    }
}
